package com.huabo.contract.oracle.mapper;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.poi.util.StringUtil;

import com.alibaba.druid.util.StringUtils;
import com.hbfk.entity.TblStaffUtil;
import com.hbfk.util.DateUtil;
import com.hbfk.util.PageInfo;
import com.huabo.contract.oracle.entity.TblCyhwProjectbudget;


public class TblCyhwProjectbudgetMapperSqlConifg {
	
	
	public String updateOppositeInfoById(TblCyhwProjectbudget tcpb,Integer sealorgid) {
		StringBuffer sql = new StringBuffer("UPDATE TBL_CYHW_PROJECTBUDGET SET BUDGETNAME = '"+tcpb.getBudgetname()+"'");
		
		
		if(sealorgid != null) {
			sql.append(" ,SEALORGID = '"+sealorgid+"'");
		}
		 
		if(tcpb.getTotaltmoney() != null) {
			sql.append(" ,TOTALTMONEY = '"+tcpb.getTotaltmoney()+"'");
		}
		if(tcpb.getFinancemoney() != null) {
			sql.append(" ,FINANCEMONEY = '"+tcpb.getFinancemoney()+"'");
		}
		if(tcpb.getOthermoney() != null) {
			sql.append(" ,OTHERMONEY = '"+tcpb.getOthermoney()+"'");
		}
		if(tcpb.getGoodstype() != null) {
			sql.append(" ,GOODSTYPE = '"+tcpb.getGoodstype()+"'");
		}
		if(tcpb.getServicetype() != null) {
			sql.append(" ,SERVICETYPE = '"+tcpb.getServicetype()+"'");
		}
		if(tcpb.getProjecttype() != null) {
			sql.append(" ,PROJECTTYPE = '"+tcpb.getProjecttype()+"'");
		}
		if(tcpb.getOrthertype() != null) {
			sql.append(" ,ORTHERTYPE = '"+tcpb.getOrthertype()+"'");
		}
		if(tcpb.getIsgovernment() != null) {
			sql.append(" ,ISGOVERNMENT = '"+tcpb.getIsgovernment()+"'");
		}
		if(tcpb.getIsdirect() != null) {
			sql.append(" ,ISDIRECT = '"+tcpb.getIsdirect()+"'");
		}
		if(tcpb.getItembudgettype() != null) {
			sql.append(" ,ITEMBUDGETTYPE = '"+tcpb.getItembudgettype()+"'");
		}
		if(tcpb.getProjecteason() != null) {
			sql.append(" ,PROJECTEASON = '"+tcpb.getProjecteason()+"'");
		}
		if(tcpb.getProjectgoal() != null) {
			sql.append(" ,PROJECTGOAL = '"+tcpb.getProjectgoal()+"'");
		}
		if(tcpb.getProjectstagegoal() != null) {
			sql.append(" ,PROJECTSTAGEGOAL = '"+tcpb.getProjectstagegoal()+"'");
		}
		if(tcpb.getProjectcondition() != null) {
			sql.append(" ,PROJECTCONDITION = '"+tcpb.getProjectcondition()+"'");
		}
		if(tcpb.getProjectrisk() != null) {
			sql.append(" ,PROJECTRISK = '"+tcpb.getProjectrisk()+"'");
		}
		if(tcpb.getCreatetime() != null) {
			sql.append(" ,CREATETIME = TO_DATE('"+DateUtil.parseDate(tcpb.getCreatetime(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getLinkdepr() != null) {
			sql.append(" ,LINKDEPR = '"+tcpb.getLinkdepr()+"'");
		}
		if(tcpb.getReporttodept() != null) {
			sql.append(" ,REPORTTODEPT = '"+tcpb.getReporttodept()+"'");
		}
		if(tcpb.getInspectionstatus() != null) {
			sql.append(" ,INSPECTIONSTATUS = '"+tcpb.getInspectionstatus()+"'");
		}
		if(tcpb.getGoodsprice() != null) {
			sql.append(" ,GOODSPRICE = '"+tcpb.getGoodsprice()+"'");
		}
		if(tcpb.getGoodsamount() != null) {
			sql.append(" ,GOODSAMOUNT = '"+tcpb.getGoodsamount()+"'");
		}
		if(tcpb.getGoodsmodel() != null) {
			sql.append(" ,GOODSMODEL = '"+tcpb.getGoodsmodel()+"'");
		}
		if(tcpb.getCounterpartno() != null) {
			sql.append(" ,COUNTERPARTNO = '"+tcpb.getCounterpartno()+"'");
		}
		if(tcpb.getCounterpartaddress() != null) {
			sql.append(" ,COUNTERPARTADDRESS = '"+tcpb.getCounterpartaddress()+"'");
		}
		if(tcpb.getCounterpartcode() != null) {
			sql.append(" ,COUNTERPARTCODE = '"+tcpb.getCounterpartcode()+"'");
		}
		if(tcpb.getCounterparthank() != null) {
			sql.append(" ,COUNTERPARTHANK = '"+tcpb.getCounterparthank()+"'");
		}
		if(tcpb.getCounterparthankaccount() != null) {
			sql.append(" ,COUNTERPARTHANKACCOUNT = '"+tcpb.getCounterparthankaccount()+"'");
		}
		if(tcpb.getCounterpartnetaddress() != null) {
			sql.append(" ,COUNTERPARTNETADDRESS = '"+tcpb.getCounterpartnetaddress()+"'");
		}
		if(tcpb.getCounterpartphone() != null) {
			sql.append(" ,COUNTERPARTPHONE = '"+tcpb.getCounterpartphone()+"'");
		}
		if(tcpb.getRecordparent() != null) {
			sql.append(" ,RECORDPARENT = '"+tcpb.getRecordparent()+"'");
		}
		if(tcpb.getRecordconcat() != null) {
			sql.append(" ,RECORDCONCAT = '"+tcpb.getRecordconcat()+"'");
		}
		if(tcpb.getAction() != null) {
			sql.append(" ,ACTION = '"+tcpb.getAction()+"'");
		}
		if(tcpb.getEqbflowid() != null) {
			sql.append(" ,EQBFLOWID = '"+tcpb.getEqbflowid()+"'");
		}
		if(tcpb.getBizno() != null) {
			sql.append(" ,BIZNO = '"+tcpb.getBizno()+"'");
		}
		if(tcpb.getResultdescription() != null) {
			sql.append(" ,RESULTDESCRIPTION = '"+tcpb.getResultdescription()+"'");
		}
		if(tcpb.getEqbstatus() != null) {
			sql.append(" ,EQBSTATUS = '"+tcpb.getEqbstatus()+"'");
		}
		if(tcpb.getFlowtype() != null) {
			sql.append(" ,FLOWTYPE = '"+tcpb.getFlowtype()+"'");
		}
		if(tcpb.getEabfileck() != null) {
			sql.append(" ,EABFILECK = '"+tcpb.getEabfileck()+"'");
		}
		if(tcpb.getFileurl() != null) {
			sql.append(" ,FILEURL = '"+tcpb.getFileurl()+"'");
		}
		if(tcpb.getOppositenature() != null) {
			sql.append(" ,OPPOSITENATURE = '"+tcpb.getOppositenature()+"'");
		}
		if(tcpb.getCounterparttype() != null) {
			sql.append(" ,COUNTERPARTTYPE = '"+tcpb.getCounterparttype()+"'");
		}
		if(tcpb.getIseffect() != null) {
			sql.append(" ,ISEFFECT = '"+tcpb.getIseffect()+"'");
		}
		if(tcpb.getCounterpartdesc() != null) {
			sql.append(" ,COUNTERPARTDESC = '"+tcpb.getCounterpartdesc()+"'");
		}
		if(tcpb.getSafeorg() != null) {
			sql.append(" ,SAFEORG = '"+tcpb.getSafeorg()+"'");
		}
		if(tcpb.getSafestaff() != null) {
			sql.append(" ,SAFESTAFF = '"+tcpb.getSafestaff()+"'");
		}
		if(tcpb.getEffectdate() != null) {
			sql.append(" ,EFFECTDATE = TO_DATE('"+DateUtil.parseDate(tcpb.getEffectdate(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getSafedate() != null) {
			sql.append(" ,SAFEDATE = TO_DATE('"+DateUtil.parseDate(tcpb.getSafedate(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getDirector() != null) {
			sql.append(" ,DIRECTOR = '"+tcpb.getDirector()+"'");
		}
		if(tcpb.getContacts() != null) {
			sql.append(" ,CONTACTS = '"+tcpb.getContacts()+"'");
		}
		if(tcpb.getContactsphone() != null) {
			sql.append(" ,CONTACTSPHONE = '"+tcpb.getContactsphone()+"'");
		}
		if(tcpb.getContactsadress() != null) {
			sql.append(" ,CONTACTSADRESS = '"+tcpb.getContactsadress()+"'");
		}
		if(tcpb.getContactsemail() != null) {
			sql.append(" ,CONTACTSEMAIL = '"+tcpb.getContactsemail()+"'");
		}
		if(tcpb.getStation() != null) {
			sql.append(" ,STATION = '"+tcpb.getStation()+"'");
		}
		if(tcpb.getCallname() != null) {
			sql.append(" ,CALLNAME = '"+tcpb.getCallname()+"'");
		}
		if(tcpb.getRemarks() != null) {
			sql.append(" ,REMARKS = '"+tcpb.getRemarks()+"'");
		}
		if(tcpb.getIsblack() != null) {
			sql.append(" ,ISBLACK = '"+tcpb.getIsblack()+"'");
		}
		if(tcpb.getBlacktype() != null) {
			sql.append(" ,BLACKTYPE = '"+tcpb.getBlacktype()+"'");
		}
		if(tcpb.getPstartdate() != null) {
			sql.append(" ,PSTARTDATE = TO_DATE('"+DateUtil.parseDate(tcpb.getPstartdate(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getPenddate() != null) {
			sql.append(" ,PENDDATE = TO_DATE('"+DateUtil.parseDate(tcpb.getPenddate(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getCretificateno() != null) {
			sql.append(" ,CRETIFICATENO = '"+tcpb.getCretificateno()+"'");
		}
		sql.append(" WHERE BUDGETID = '"+tcpb.getBudgetid()+"'");
		return sql.toString();
	}
	
	
	
	public String selectListByPageInfo(PageInfo<TblCyhwProjectbudget> pageInfo, TblStaffUtil staff, Integer taskCount) {
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT * from TBL_CYHW_PROJECTBUDGET TCP where ORGID = "+staff.getCurrentOrg().getOrgid());
		
		if(taskCount > 0) {
			sqlSb.append(" and (BUDGETID in (select FROMID from TBL_MY_TASK where USRID = "+staff.getStaffid()+" ) or CREATEUSER = "+staff.getStaffid()+" )");
		}
		TblCyhwProjectbudget budget = pageInfo.getCondition();
		if(budget.getBudgetname() != null && !"".equals(budget.getBudgetname())) {
			sqlSb.append(" AND TCP.BUDGETNAME LIKE '%"+budget.getBudgetname()+"%'");
		}
		if(budget.getFlowid() != null && !"".equals(budget.getFlowid())) {
			sqlSb.append(" AND TCP.FLOWID = "+budget.getFlowid()+"");
		}
		if(budget.getRecordtype() != null && !"".equals(budget.getRecordtype())) {
			sqlSb.append(" AND TCP.RECORDTYPE = '"+pageInfo.getCondition().getRecordtype()+"'");
		}
		if(budget.getInspectionstatus() != null && !"".equals(budget.getInspectionstatus())) {
			sqlSb.append(" AND TCP.INSPECTIONSTATUS = '"+budget.getInspectionstatus()+"'");
		}
		if(budget.getCounterpartno()!=null && !"".equals(budget.getCounterpartno())) {
			sqlSb.append(" AND TCP.COUNTERPARTNO LIKE '%"+budget.getCounterpartno().trim()+"%'");
		}
		if(budget.getProjectstagegoal() != null && !"".equals(budget.getProjectgoal())) {
			sqlSb.append(" AND TCP.PROJECTSTAGEGOAL LIKE '%"+budget.getProjectstagegoal()+"%'");
		}
		if(budget.getCounterpartaddress() != null && !"".equals(budget.getCounterpartaddress())) {
			sqlSb.append(" AND TCP.COUNTERPARTADDRESS LIKE '%"+budget.getCounterpartaddress().trim()+"%'");
		}
		if(budget.getBlacktype() != null && budget.getBlacktype()==3) {
			
		}
		if(budget.getIsblack() != null) {
			if( budget.getBlacktype()==3) {
				sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
			}else if(budget.getIsblack() == 2) {
				sqlSb.append(" AND ISBLACK = 2");
			}else if(budget.getIsblack() == 1) {
				sqlSb.append(" AND (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE)");
			}
		}
		sqlSb.append(" ORDER BY BUDGETID DESC ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}

	public String selectListByPageInfoFlowid(PageInfo<TblCyhwProjectbudget> pageInfo, TblStaffUtil staff, Integer taskCount, String flowid) {
//		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT * from TBL_CYHW_PROJECTBUDGET TCP  \n" +
//				"LEFT JOIN TBL_COUNTERPART_BANKINFO TCB ON TCP.BUDGETID = TCB.BUDGETID  where ORGID = "+staff.getCurrentOrg().getOrgid()+" and TCP.FLOWID ="+622322);
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT * from TBL_CYHW_PROJECTBUDGET TCP  " +
				" where ORGID = "+staff.getCurrentOrg().getOrgid()+" and TCP.FLOWID = 622322");
		if(taskCount > 0) {
			sqlSb.append(" and (TCP.BUDGETID in (select FROMID from TBL_MY_TASK where USRID = "+staff.getStaffid()+" ) or TCP.CREATEUSER = "+staff.getStaffid()+" )");
		}
		TblCyhwProjectbudget budget = pageInfo.getCondition();
		if(budget.getBudgetname() != null && !"".equals(budget.getBudgetname())) {
			sqlSb.append(" AND TCP.BUDGETNAME LIKE '%"+budget.getBudgetname()+"%'");
		}
//		if(budget.getFlowid() != null && !"".equals(budget.getFlowid())) {
//			sqlSb.append(" AND TCP.FLOWID = "+budget.getFlowid()+"");
//		}
		if(budget.getRecordtype() != null && !"".equals(budget.getRecordtype())) {
			sqlSb.append(" AND TCP.RECORDTYPE = '"+pageInfo.getCondition().getRecordtype()+"'");
		}
		if(budget.getInspectionstatus() != null && !"".equals(budget.getInspectionstatus())) {
			sqlSb.append(" AND TCP.INSPECTIONSTATUS = '"+budget.getInspectionstatus()+"'");
		}
		if(budget.getCounterpartno()!=null && !"".equals(budget.getCounterpartno())) {
			sqlSb.append(" AND TCP.COUNTERPARTNO LIKE '%"+budget.getCounterpartno().trim()+"%'");
		}
		if(budget.getProjectstagegoal() != null && !"".equals(budget.getProjectgoal())) {
			sqlSb.append(" AND TCP.PROJECTSTAGEGOAL LIKE '%"+budget.getProjectgoal().trim()+"%'");
		}
		if(budget.getCounterpartaddress() != null && !"".equals(budget.getCounterpartaddress())) {
			sqlSb.append(" AND TCP.COUNTERPARTADDRESS LIKE '%"+budget.getCounterpartaddress().trim()+"%'");
		}
		if(budget.getBlacktype() != null && budget.getBlacktype()==3) {

		}
		if(budget.getIsblack() != null) {
			if( budget.getBlacktype()==3) {
				sqlSb.append(" AND ((TCP.ISBLACK = 2 OR TCP.ISBLACK IS NULL) OR (TCP.ISBLACK = 1 AND TCP.BLACKTYPE = 1 AND TCP.EFFECTDATE <= SYSDATE))");
			}else if(budget.getIsblack() == 2) {
				sqlSb.append(" AND TCP.ISBLACK = 2");
			}else if(budget.getIsblack() == 1) {
				sqlSb.append(" AND (TCP.ISBLACK = 1 AND TCP.BLACKTYPE = 1 AND TCP.EFFECTDATE <= SYSDATE)");
			}
		}
		sqlSb.append(" ORDER BY TCP.BUDGETID DESC ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}

	public String selectListByPageInfoFlowidCount(TblStaffUtil staff, Integer taskCount, String flowid) {
		StringBuffer sqlSb = new StringBuffer("SELECT COUNT(*) from TBL_CYHW_PROJECTBUDGET TCP  \n" +
				"  where ORGID = "+staff.getCurrentOrg().getOrgid()+" and TCP.FLOWID ="+622322);

		if(taskCount > 0) {
			sqlSb.append(" and (TCP.BUDGETID in (select FROMID from TBL_MY_TASK where USRID = "+staff.getStaffid()+" ) or TCP.CREATEUSER = "+staff.getStaffid()+" )");
		}
		TblCyhwProjectbudget budget = new TblCyhwProjectbudget();
		if(budget.getBudgetname() != null && !"".equals(budget.getBudgetname())) {
			sqlSb.append(" AND TCP.BUDGETNAME LIKE '%"+budget.getBudgetname()+"%'");
		}
//		if(budget.getFlowid() != null && !"".equals(budget.getFlowid())) {
//			sqlSb.append(" AND TCP.FLOWID = "+budget.getFlowid()+"");
//		}
//		if(budget.getRecordtype() != null && !"".equals(budget.getRecordtype())) {
//			sqlSb.append(" AND TCP.RECORDTYPE = '"+pageInfo.getCondition().getRecordtype()+"'");
//		}
		if(budget.getInspectionstatus() != null && !"".equals(budget.getInspectionstatus())) {
			sqlSb.append("AND TCP.INSPECTIONSTATUS = '"+budget.getInspectionstatus()+"'");
		}
		if(budget.getCounterpartno()!=null && !"".equals(budget.getCounterpartno())) {
			sqlSb.append(" AND TCP.COUNTERPARTNO LIKE '%"+budget.getCounterpartno().trim()+"%'");
		}
		if(budget.getProjectstagegoal() != null && !"".equals(budget.getProjectgoal())) {
			sqlSb.append(" AND TCP.PROJECTSTAGEGOAL LIKE '%"+budget.getProjectgoal().trim()+"%'");
		}
		if(budget.getCounterpartaddress() != null && !"".equals(budget.getCounterpartaddress())) {
			sqlSb.append(" AND TCP.COUNTERPARTADDRESS LIKE '%"+budget.getCounterpartaddress().trim()+"%'");
		}
		if(budget.getBlacktype() != null && budget.getBlacktype()==3) {

		}
		if(budget.getIsblack() != null) {
			if( budget.getBlacktype()==3) {
				sqlSb.append(" AND ((TCP.ISBLACK = 2 OR TCP.ISBLACK IS NULL) OR (TCP.ISBLACK = 1 AND TCP.BLACKTYPE = 1 AND TCP.EFFECTDATE <= SYSDATE))");
			}else if(budget.getIsblack() == 2) {
				sqlSb.append(" AND TCP.ISBLACK = 2");
			}else if(budget.getIsblack() == 1) {
				sqlSb.append(" AND (TCP.ISBLACK = 1 AND TCP.BLACKTYPE = 1 AND TCP.EFFECTDATE <= SYSDATE)");
			}
		}
		sqlSb.append(" ORDER BY TCP.BUDGETID DESC ");
		String sql = sqlSb.toString();
		return sql;
	}

	
	public String selectCountByPageInfo(PageInfo<TblCyhwProjectbudget> pageInfo, TblStaffUtil staff, Integer taskCount) {
		StringBuffer sqlSb = new StringBuffer("SELECT COUNT(0) from TBL_CYHW_PROJECTBUDGET where ORGID = "+staff.getCurrentOrg().getOrgid());
		if(taskCount > 0) {
			sqlSb.append(" and (BUDGETID in (select FROMID from TBL_MY_TASK where USRID = "+staff.getStaffid()+" ) or CREATEUSER = "+staff.getStaffid()+" )");
		}
		TblCyhwProjectbudget budget = pageInfo.getCondition();
		if(budget.getBudgetname() != null && !"".equals(budget.getBudgetname())) {
			sqlSb.append(" AND budgetName LIKE '%"+budget.getBudgetname()+"%'");
		}
		if(budget.getFlowid() != null && !"".equals(budget.getFlowid())) {
			sqlSb.append(" AND FLOWID = "+budget.getFlowid()+"");
		}
		if(budget.getRecordtype() != null && !"".equals(budget.getRecordtype())) {
			sqlSb.append(" AND RECORDTYPE = '"+pageInfo.getCondition().getRecordtype()+"'");
		}
		if(budget.getInspectionstatus() != null && !"".equals(budget.getInspectionstatus())) {
			sqlSb.append("AND INSPECTIONSTATUS = '"+budget.getInspectionstatus()+"'");
		}
		if(budget.getCounterpartno()!=null && !"".equals(budget.getCounterpartno())) {
			sqlSb.append(" AND counterpartNo LIKE '%"+budget.getCounterpartno()+"%'");
		}
		if(budget.getProjectstagegoal() != null && !"".equals(budget.getProjectgoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%"+budget.getProjectgoal()+"%'");
		}
		if(budget.getCounterpartaddress() != null && !"".equals(budget.getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%"+budget.getCounterpartaddress()+"%'");
		}
		if(budget.getIsblack() != null) {
			if( budget.getBlacktype()==3) {
				sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
			}else if(budget.getIsblack() == 2) {
				sqlSb.append(" AND ISBLACK = 2");
			}else if(budget.getIsblack() == 1) {
				sqlSb.append(" AND (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE)");
			}
		}
		String sql = sqlSb.toString();
		return sql;
	}

	public String selectCountByPageInfoCount(TblStaffUtil staff, Integer taskCount) {
		StringBuffer sqlSb = new StringBuffer("SELECT COUNT(*) from TBL_CYHW_PROJECTBUDGET where ORGID = "+staff.getCurrentOrg().getOrgid());
		if(taskCount > 0) {
			sqlSb.append(" and (BUDGETID in (select FROMID from TBL_MY_TASK where USRID = "+staff.getStaffid()+" ) or CREATEUSER = "+staff.getStaffid()+" )");
		}
		TblCyhwProjectbudget budget = new TblCyhwProjectbudget();
		if(budget.getBudgetname() != null && !"".equals(budget.getBudgetname())) {
			sqlSb.append(" AND budgetName LIKE '%"+budget.getBudgetname()+"%'");
		}
		if(budget.getFlowid() != null && !"".equals(budget.getFlowid())) {
			sqlSb.append(" AND FLOWID = "+budget.getFlowid()+"");
		}
//		if(budget.getRecordtype() != null && !"".equals(budget.getRecordtype())) {
//			sqlSb.append(" AND RECORDTYPE = '"+pageInfo.getCondition().getRecordtype()+"'");
//		}
		if(budget.getInspectionstatus() != null && !"".equals(budget.getInspectionstatus())) {
			sqlSb.append("AND INSPECTIONSTATUS = '"+budget.getInspectionstatus()+"'");
		}
		if(budget.getCounterpartno()!=null && !"".equals(budget.getCounterpartno())) {
			sqlSb.append(" AND counterpartNo LIKE '%"+budget.getCounterpartno().trim()+"%'");
		}
		if(budget.getProjectstagegoal() != null && !"".equals(budget.getProjectgoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%"+budget.getProjectgoal().trim()+"%'");
		}
		if(budget.getCounterpartaddress() != null && !"".equals(budget.getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%"+budget.getCounterpartaddress().trim()+"%'");
		}
		if(budget.getIsblack() != null) {
			if( budget.getBlacktype()==3) {
				sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
			}else if(budget.getIsblack() == 2) {
				sqlSb.append(" AND ISBLACK = 2");
			}else if(budget.getIsblack() == 1) {
				sqlSb.append(" AND (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE)");
			}
		}
		String sql = sqlSb.toString();
		return sql;
	}
	
	public String selectRepearBudgetName(String budgetname, BigDecimal orgid, Integer budgetId) {
		String sql = "SELECT COUNT(0) FROM TBL_CYHW_PROJECTBUDGET WHERE BUDGETNAME ='"+budgetname+"' AND ORGID = '"+orgid+"'";
		if(budgetId != null) {
			sql += " AND BUDGETID != "+budgetId;
		}
		return sql;
	}

	
	public String insertOppositeParty(TblCyhwProjectbudget tcpb,Integer sealorgid) {
		StringBuffer column = new StringBuffer("INSERT INTO TBL_CYHW_PROJECTBUDGET (BUDGETID");
		StringBuffer value = new StringBuffer(" VALUES (CYHWBUDGET_SEQUENCE.nextval");
		
		
		if(sealorgid != null) {
			column.append(",SEALORGID");
			value.append(",'"+sealorgid+"'");
		}
		
		if(tcpb.getBudgetname() != null) {
			column.append(",BUDGETNAME");
			value.append(",'"+tcpb.getBudgetname()+"'");
		}
		if(tcpb.getTotaltmoney() != null) {
			column.append(",TOTALTMONEY");
			value.append(",'"+tcpb.getTotaltmoney()+"'");
		}
		if(tcpb.getFinancemoney() != null) {
			column.append(",FINANCEMONEY");
			value.append(",'"+tcpb.getFinancemoney()+"'");
		}
		if(tcpb.getOthermoney() != null) {
			column.append(",OTHERMONEY");
			value.append(",'"+tcpb.getOthermoney()+"'");
		}
		if(tcpb.getGoodstype() != null) {
			column.append(",GOODSTYPE");
			value.append(",'"+tcpb.getGoodstype()+"'");
		}
		if(tcpb.getServicetype() != null) {
			column.append(",SERVICETYPE");
			value.append(",'"+tcpb.getServicetype()+"'");
		}
		if(tcpb.getProjecttype() != null) {
			column.append(",PROJECTTYPE");
			value.append(",'"+tcpb.getProjecttype()+"'");
		}
		if(tcpb.getOrthertype() != null) {
			column.append(",ORTHERTYPE");
			value.append(",'"+tcpb.getOrthertype()+"'");
		}
		if(tcpb.getIsgovernment() != null) {
			column.append(",ISGOVERNMENT");
			value.append(",'"+tcpb.getIsgovernment()+"'");
		}
		if(tcpb.getIsdirect() != null) {
			column.append(",ISDIRECT");
			value.append(",'"+tcpb.getIsdirect()+"'");
		}
		if(tcpb.getItembudgettype() != null) {
			column.append(",ITEMBUDGETTYPE");
			value.append(",'"+tcpb.getItembudgettype()+"'");
		}
		if(tcpb.getProjecteason() != null) {
			column.append(",PROJECTEASON");
			value.append(",'"+tcpb.getProjecteason()+"'");
		}
		if(tcpb.getProjectgoal() != null) {
			column.append(",PROJECTGOAL");
			value.append(",'"+tcpb.getProjectgoal()+"'");
		}
		if(tcpb.getProjectstagegoal() != null) {
			column.append(",PROJECTSTAGEGOAL");
			value.append(",'"+tcpb.getProjectstagegoal()+"'");
		}
		if(tcpb.getProjectcondition() != null) {
			column.append(",PROJECTCONDITION");
			value.append(",'"+tcpb.getProjectcondition()+"'");
		}
		if(tcpb.getProjectrisk() != null) {
			column.append(",PROJECTRISK");
			value.append(",'"+tcpb.getProjectrisk()+"'");
		}
		if(tcpb.getOrgid() != null) {
			column.append(",ORGID");
			value.append(",'"+tcpb.getOrgid()+"'");
		}
		if(tcpb.getCreateuser() != null) {
			column.append(",CREATEUSER");
			value.append(",'"+tcpb.getCreateuser()+"'");
		}
		if(tcpb.getCreatetime() != null) {
			column.append(",CREATETIME");
			value.append(",TO_DATE('"+DateUtil.parseDate(tcpb.getCreatetime(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getFlowid() != null) {
			column.append(",FLOWID");
			value.append(",'"+tcpb.getFlowid()+"'");
		}
		if(tcpb.getLinkdepr() != null) {
			column.append(",LINKDEPR");
			value.append(",'"+tcpb.getLinkdepr()+"'");
		}
		if(tcpb.getReporttodept() != null) {
			column.append(",REPORTTODEPT");
			value.append(",'"+tcpb.getReporttodept()+"'");
		}
		if(tcpb.getInspectionstatus() != null) {
			column.append(",INSPECTIONSTATUS");
			value.append(",'"+tcpb.getInspectionstatus()+"'");
		}
		if(tcpb.getGoodsprice() != null) {
			column.append(",GOODSPRICE");
			value.append(",'"+tcpb.getGoodsprice()+"'");
		}
		if(tcpb.getGoodsamount() != null) {
			column.append(",GOODSAMOUNT");
			value.append(",'"+tcpb.getGoodsamount()+"'");
		}
		if(tcpb.getGoodsmodel() != null) {
			column.append(",GOODSMODEL");
			value.append(",'"+tcpb.getGoodsmodel()+"'");
		}
		if(tcpb.getCounterpartno() != null) {
			column.append(",COUNTERPARTNO");
			value.append(",'"+tcpb.getCounterpartno()+"'");
		}
		if(tcpb.getCounterpartaddress() != null) {
			column.append(",COUNTERPARTADDRESS");
			value.append(",'"+tcpb.getCounterpartaddress()+"'");
		}
		if(tcpb.getCounterpartcode() != null) {
			column.append(",COUNTERPARTCODE");
			value.append(",'"+tcpb.getCounterpartcode()+"'");
		}
		if(tcpb.getCounterparthank() != null) {
			column.append(",COUNTERPARTHANK");
			value.append(",'"+tcpb.getCounterparthank()+"'");
		}
		if(tcpb.getCounterparthankaccount() != null) {
			column.append(",COUNTERPARTHANKACCOUNT");
			value.append(",'"+tcpb.getCounterparthankaccount()+"'");
		}
		if(tcpb.getCounterpartnetaddress() != null) {
			column.append(",COUNTERPARTNETADDRESS");
			value.append(",'"+tcpb.getCounterpartnetaddress()+"'");
		}
		if(tcpb.getCounterpartphone() != null) {
			column.append(",COUNTERPARTPHONE");
			value.append(",'"+tcpb.getCounterpartphone()+"'");
		}
		if(tcpb.getRecordtype() != null) {
			column.append(",RECORDTYPE");
			value.append(",'"+tcpb.getRecordtype()+"'");
		}
		if(tcpb.getRecordparent() != null) {
			column.append(",RECORDPARENT");
			value.append(",'"+tcpb.getRecordparent()+"'");
		}
		if(tcpb.getRecordconcat() != null) {
			column.append(",RECORDCONCAT");
			value.append(",'"+tcpb.getRecordconcat()+"'");
		}
		if(tcpb.getAction() != null) {
			column.append(",ACTION");
			value.append(",'"+tcpb.getAction()+"'");
		}
		if(tcpb.getEqbflowid() != null) {
			column.append(",EQBFLOWID");
			value.append(",'"+tcpb.getEqbflowid()+"'");
		}
		if(tcpb.getBizno() != null) {
			column.append(",BIZNO");
			value.append(",'"+tcpb.getBizno()+"'");
		}
		if(tcpb.getResultdescription() != null) {
			column.append(",RESULTDESCRIPTION");
			value.append(",'"+tcpb.getResultdescription()+"'");
		}
		if(tcpb.getEqbstatus() != null) {
			column.append(",EQBSTATUS");
			value.append(",'"+tcpb.getEqbstatus()+"'");
		}
		if(tcpb.getFlowtype() != null) {
			column.append(",FLOWTYPE");
			value.append(",'"+tcpb.getFlowtype()+"'");
		}
		if(tcpb.getEabfileck() != null) {
			column.append(",EABFILECK");
			value.append(",'"+tcpb.getEabfileck()+"'");
		}
		if(tcpb.getFileurl() != null) {
			column.append(",FILEURL");
			value.append(",'"+tcpb.getFileurl()+"'");
		}
		if(tcpb.getOppositenature() != null) {
			column.append(",OPPOSITENATURE");
			value.append(",'"+tcpb.getOppositenature()+"'");
		}
		if(tcpb.getCounterparttype() != null) {
			column.append(",COUNTERPARTTYPE");
			value.append(",'"+tcpb.getCounterparttype()+"'");
		}
		if(tcpb.getIseffect() != null) {
			column.append(",ISEFFECT");
			value.append(",'"+tcpb.getIseffect()+"'");
		}
		if(tcpb.getCounterpartdesc() != null) {
			column.append(",COUNTERPARTDESC");
			value.append(",'"+tcpb.getCounterpartdesc()+"'");
		}
		if(tcpb.getSafeorg() != null) {
			column.append(",SAFEORG");
			value.append(",'"+tcpb.getSafeorg()+"'");
		}
		if(tcpb.getSafestaff() != null) {
			column.append(",SAFESTAFF");
			value.append(",'"+tcpb.getSafestaff()+"'");
		}
		if(tcpb.getEffectdate() != null) {
			column.append(",EFFECTDATE");
			value.append(",TO_DATE('"+DateUtil.parseDate(tcpb.getEffectdate(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getSafedate() != null) {
			column.append(",SAFEDATE");
			value.append(",TO_DATE('"+DateUtil.parseDate(tcpb.getSafedate(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getDirector() != null) {
			column.append(",DIRECTOR");
			value.append(",'"+tcpb.getDirector()+"'");
		}
		if(tcpb.getContacts() != null) {
			column.append(",CONTACTS");
			value.append(",'"+tcpb.getContacts()+"'");
		}
		if(tcpb.getContactsphone() != null) {
			column.append(",CONTACTSPHONE");
			value.append(",'"+tcpb.getContactsphone()+"'");
		}
		if(tcpb.getContactsadress() != null) {
			column.append(",CONTACTSADRESS");
			value.append(",'"+tcpb.getContactsadress()+"'");
		}
		if(tcpb.getContactsemail() != null) {
			column.append(",CONTACTSEMAIL");
			value.append(",'"+tcpb.getContactsemail()+"'");
		}
		if(tcpb.getStation() != null) {
			column.append(",STATION");
			value.append(",'"+tcpb.getStation()+"'");
		}
		if(tcpb.getCallname() != null) {
			column.append(",CALLNAME");
			value.append(",'"+tcpb.getCallname()+"'");
		}
		if(tcpb.getRemarks() != null) {
			column.append(",REMARKS");
			value.append(",'"+tcpb.getRemarks()+"'");
		}
		if(tcpb.getIsblack() != null) {
			column.append(",ISBLACK");
			value.append(",'"+tcpb.getIsblack()+"'");
		}
		if(tcpb.getBlacktype() != null) {
			column.append(",BLACKTYPE");
			value.append(",'"+tcpb.getBlacktype()+"'");
		}
		if(tcpb.getPstartdate() != null) {
			column.append(",PSTARTDATE");
			value.append(",TO_DATE('"+DateUtil.parseDate(tcpb.getPstartdate(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getPenddate() != null) {
			column.append(",PENDDATE");
			value.append(",TO_DATE('"+DateUtil.parseDate(tcpb.getPenddate(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getCretificateno() != null) {
			column.append(",CRETIFICATENO");
			value.append(",'"+tcpb.getCretificateno()+"'");
		}
		column.append(")");
		value.append(")");
		String sql = column.toString()+value.toString();
		return sql;
	}


	public String findCollectionChoiceContractPid(PageInfo<TblCyhwProjectbudget> pageInfo, TblCyhwProjectbudget tcpb) {
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT BUDGETID,BUDGETNAME,COUNTERPARTNO,PROJECTSTAGEGOAL,COUNTERPARTADDRESS,COUNTERPARTHANK,TOTALTMONEY,RESULTDESCRIPTION FROM TBL_CYHW_PROJECTBUDGET WHERE RECORDTYPE = 'HTGL001' AND INSPECTIONSTATUS = " + tcpb.getInspectionstatus() + " AND ORGID = " + tcpb.getOrgid());
		if (tcpb.getBudgetname() != null && !"".equals(tcpb.getBudgetname())) {
			sqlSb.append(" AND BUDGETNAME LIKE '%" + tcpb.getBudgetname() + "%'");
		}
		if (tcpb.getCounterpartno() != null && !"".equals(tcpb.getCounterpartno())) {
			sqlSb.append(" AND COUNTERPARTNO LIKE '%" + tcpb.getCounterpartno() + "%'");
		}
		if ((tcpb.getIsblack() != null && (tcpb.getIsblack() == 2))) {
			sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
		}
		sqlSb.append(" ORDER BY BUDGETID DESC) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}

	public String findCollectionChoiceContractPidCount(TblCyhwProjectbudget tcpb) {
		StringBuffer sqlSb = new StringBuffer("SELECT COUNT(*) FROM TBL_CYHW_PROJECTBUDGET WHERE RECORDTYPE = 'HTGL001' AND INSPECTIONSTATUS = " + tcpb.getInspectionstatus() + " AND ORGID = " + tcpb.getOrgid());
		if (tcpb.getBudgetname() != null && !"".equals(tcpb.getBudgetname())) {
			sqlSb.append(" AND BUDGETNAME LIKE '%" + tcpb.getBudgetname() + "%'");
		}
		if (tcpb.getCounterpartno() != null && !"".equals(tcpb.getCounterpartno())) {
			sqlSb.append(" AND COUNTERPARTNO LIKE '%" + tcpb.getCounterpartno() + "%'");
		}
		if ((tcpb.getIsblack() != null && (tcpb.getIsblack() == 2))) {
			sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
		}

		String sql = sqlSb.toString();
		return sql;
	}

	public String findListByPageInfo(PageInfo<TblCyhwProjectbudget> pageInfo,String orgid) throws Exception {
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT T.* from TBL_CYHW_PROJECTBUDGET T where  1 = 1 ");
		if(pageInfo.getCondition().getBudgetname()!=null && !"".equals(pageInfo.getCondition().getBudgetname())){
			sqlSb.append("  AND BUDGETNAME LIKE '%"+pageInfo.getCondition().getBudgetname()+"%'");
		}
		if(pageInfo.getCondition().getFlowid()!=null && !"".equals(pageInfo.getCondition().getFlowid())){
			sqlSb.append(" and FLOWID="+pageInfo.getCondition().getFlowid());
		}
		if(pageInfo.getCondition().getRecordtype() != null && !"".equals(pageInfo.getCondition().getRecordtype())){
			sqlSb.append(" AND RECORDTYPE = '"+pageInfo.getCondition().getRecordtype()+"'");
		}
		if(pageInfo.getCondition().getInspectionstatus() != null && !"".equals(pageInfo.getCondition().getInspectionstatus())){
			sqlSb.append(" AND INSPECTIONSTATUS = '"+pageInfo.getCondition().getInspectionstatus()+"'");

		}
		if(pageInfo.getCondition().getCounterpartno()!=null && !"".equals(pageInfo.getCondition().getCounterpartno())) {
			sqlSb.append(" AND counterpartNo LIKE '%"+pageInfo.getCondition().getCounterpartno().trim()+"%'");

		}
		if(pageInfo.getCondition().getProjectstagegoal()!=null && !"".equals(pageInfo.getCondition().getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%"+pageInfo.getCondition().getProjectstagegoal().trim()+"%'");

		}
		if(pageInfo.getCondition().getCounterpartaddress()!=null && !"".equals(pageInfo.getCondition().getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%"+pageInfo.getCondition().getCounterpartaddress().trim()+"%'");

		}
		if(pageInfo.getCondition().getBlacktype()!=null&&pageInfo.getCondition().getBlacktype()==3) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");

		}
		if(pageInfo.getCondition().getIsblack() != null) {
			if(pageInfo.getCondition().getIsblack() == 2) {
				sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");

			}
		}
		sqlSb.append(" ORDER BY BUDGETID DESC) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}
	public String findCountByPageInfoCount(PageInfo<TblCyhwProjectbudget> pageInfo,String orgid) throws Exception {
		StringBuffer sqlSb = new StringBuffer("SELECT COUNT(*) from TBL_CYHW_PROJECTBUDGET where 1 = 1 ");
		if(pageInfo.getCondition().getBudgetname()!=null && !"".equals(pageInfo.getCondition().getBudgetname())){
			sqlSb.append("  AND budgetName LIKE '%"+pageInfo.getCondition().getBudgetname()+"%'");
		}
		if(pageInfo.getCondition().getFlowid()!=null && !"".equals(pageInfo.getCondition().getFlowid())){
			sqlSb.append(" and FLOWID="+pageInfo.getCondition().getFlowid());
		}
		if(pageInfo.getCondition().getRecordtype() != null && !"".equals(pageInfo.getCondition().getRecordtype())){
			sqlSb.append(" AND RECORDTYPE = '"+pageInfo.getCondition().getRecordtype()+"'");
		}
		if(pageInfo.getCondition().getInspectionstatus() != null && !"".equals(pageInfo.getCondition().getInspectionstatus())){
			sqlSb.append(" AND INSPECTIONSTATUS = '"+pageInfo.getCondition().getInspectionstatus()+"'");

		}
		if(pageInfo.getCondition().getCounterpartno()!=null && !"".equals(pageInfo.getCondition().getCounterpartno())) {
			sqlSb.append(" AND counterpartNo LIKE '%"+pageInfo.getCondition().getCounterpartno().trim()+"%'");

		}
		if(pageInfo.getCondition().getProjectstagegoal()!=null && !"".equals(pageInfo.getCondition().getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%"+pageInfo.getCondition().getProjectstagegoal().trim()+"%'");

		}
		if(pageInfo.getCondition().getCounterpartaddress()!=null && !"".equals(pageInfo.getCondition().getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%"+pageInfo.getCondition().getCounterpartaddress().trim()+"%'");

		}
		if(pageInfo.getCondition().getBlacktype()!=null&&pageInfo.getCondition().getBlacktype()==3) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");

		}
		if(pageInfo.getCondition().getIsblack() != null) {
			if(pageInfo.getCondition().getIsblack() == 2) {
				sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");

			}
		}
		return sqlSb.toString();
	}


	public String findListByPageInfoOrgid(PageInfo<TblCyhwProjectbudget> pageInfo, BigDecimal orgid) throws Exception {
		TblCyhwProjectbudget budget = new TblCyhwProjectbudget();
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT T.* from TBL_CYHW_PROJECTBUDGET T where ORGID=  "+ orgid);

		if (budget.getBudgetname() != null && !"".equals(budget.getBudgetname())) {
			sqlSb.append("  AND budgetName LIKE '%" + (budget.getBudgetname() + "%'") );
			//sqlSb.append( "  AND budgetName LIKE '%" + (budget.getBudgetname() + "%'") );
		}

		if (budget.getFlowid() != null && !"".equals(budget.getFlowid())) {
			sqlSb.append( " and FLOWID=" + (budget.getFlowid()));
			//sqlSb.append(" and FLOWID=" + (budget.getFlowid())) ;
		}

		if (budget.getRecordtype() != null && !"".equals(budget.getRecordtype())) {
			sqlSb.append(" AND RECORDTYPE = '" + (budget.getRecordtype() + "'") );
			//sqlSb.append( " AND RECORDTYPE = '" + (budget.getRecordtype() + "'"));
		}

		if (budget.getInspectionstatus() != null && !"".equals(budget.getInspectionstatus())) {
			sqlSb.append(" AND INSPECTIONSTATUS = '" + (budget.getInspectionstatus() + "'"));
			//sqlSb.append( " AND INSPECTIONSTATUS = '" + (budget.getInspectionstatus()+ "'"));
		}

		if (budget.getCounterpartno() != null && !"".equals(budget.getCounterpartno())) {
			sqlSb.append(" AND counterpartNo LIKE '%" + (budget.getCounterpartno()+ "%'"));
			//sqlSb.append(" AND counterpartNo LIKE '%" + (budget.getCounterpartno() + "%'"));
		}

		if (budget.getProjectstagegoal() != null && !"".equals(budget.getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + (budget.getProjectstagegoal() + "%'"));
			//sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + (budget.getProjectstagegoal() + "%'"));
		}

		if (budget.getCounterpartaddress() != null && !"".equals(budget.getCounterpartaddress())) {
			sqlSb.append( " AND COUNTERPARTADDRESS LIKE '%" + (budget.getCounterpartaddress() + "%'"));
			//sqlSb.append( " AND COUNTERPARTADDRESS LIKE '%" + (budget.getCounterpartaddress() + "%'"));
		}

		if (budget.getBlacktype() != null && (budget.getBlacktype() == 3)) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");
			//sqlSb.append(" AND BLACKTYPE IS NOT NULL");
		}

		if (budget.getIsblack() != null && (budget.getIsblack() == 2)) {
			sqlSb.append( " AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
		//	sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
		}

		sqlSb.append(" ORDER BY BUDGETID DESC ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}

	public String findListByPageInfoCount(PageInfo<TblCyhwProjectbudget> pageInfo, BigDecimal orgid) throws Exception {
		TblCyhwProjectbudget budget = new TblCyhwProjectbudget();
		StringBuffer sqlSb = new StringBuffer("SELECT T.* from TBL_CYHW_PROJECTBUDGET T where ORGID=  "+ orgid);

		if (budget.getBudgetname() != null && !"".equals(budget.getBudgetname())) {
			//sqlSb.append("  AND budgetName LIKE '%" + (budget.getBudgetname() + "%'") );
			sqlSb.append( "  AND budgetName LIKE '%" + (budget.getBudgetname() + "%'") );
		}

		if (budget.getFlowid() != null && !"".equals(budget.getFlowid())) {
			//sqlSb.append( " and FLOWID=" + (budget.getFlowid()));
			sqlSb.append(" and FLOWID=" + (budget.getFlowid())) ;
		}

		if (budget.getRecordtype() != null && !"".equals(budget.getRecordtype())) {
			//sqlSb.append(" AND RECORDTYPE = '" + (budget.getRecordtype() + "'") );
			sqlSb.append( " AND RECORDTYPE = '" + (budget.getRecordtype() + "'"));
		}

		if (budget.getInspectionstatus() != null && !"".equals(budget.getInspectionstatus())) {
			//sqlSb.append(" AND INSPECTIONSTATUS = '" + (budget.getInspectionstatus() + "'"));
			sqlSb.append( " AND INSPECTIONSTATUS = '" + (budget.getInspectionstatus()+ "'"));
		}

		if (budget.getCounterpartno() != null && !"".equals(budget.getCounterpartno())) {
			//sqlSb.append(" AND counterpartNo LIKE '%" + (budget.getCounterpartno()+ "%'"));
			sqlSb.append(" AND counterpartNo LIKE '%" + (budget.getCounterpartno() + "%'"));
		}

		if (budget.getProjectstagegoal() != null && !"".equals(budget.getProjectstagegoal())) {
			//sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + (budget.getProjectstagegoal() + "%'"));
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + (budget.getProjectstagegoal() + "%'"));
		}

		if (budget.getCounterpartaddress() != null && !"".equals(budget.getCounterpartaddress())) {
			//sqlSb.append( " AND COUNTERPARTADDRESS LIKE '%" + (budget.getCounterpartaddress() + "%'"));
			sqlSb.append( " AND COUNTERPARTADDRESS LIKE '%" + (budget.getCounterpartaddress() + "%'"));
		}

		if (budget.getBlacktype() != null && (budget.getBlacktype() == 3)) {
			//sqlSb.append(" AND BLACKTYPE IS NOT NULL");
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");
		}

		if (budget.getIsblack() != null && (budget.getIsblack() == 2)) {
			//sqlSb.append( " AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
			sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
		}

		//sqlSb.append(" ORDER BY BUDGETID DESC) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}


	public String findListByPage(PageInfo<TblCyhwProjectbudget> pageInfo, String userid,BigDecimal orgid) throws Exception {
		TblCyhwProjectbudget budget = new TblCyhwProjectbudget();
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT * from TBL_CYHW_PROJECTBUDGET where ORGID=" + orgid + "  and (BUDGETID in (select FROMID from TBL_MY_TASK where USRID=" + userid + ") or CREATEUSER=" + userid );

		if (budget.getBudgetname() != null && !"".equals(budget.getBudgetname())) {
			sqlSb.append(" AND BUDGETNAME LIKE '%" + (budget.getBudgetname() + "%'"));
		}

		if (budget.getCounterpartno() != null && !"".equals(budget.getCounterpartno())) {
			sqlSb.append( " AND COUNTERPARTNO LIKE '%" + (budget.getCounterpartno().trim() + "%'"));
		}

		if (budget.getProjectstagegoal() != null && !"".equals(budget.getProjectstagegoal())) {
			sqlSb.append( " AND PROJECTSTAGEGOAL LIKE '%" + (budget.getProjectstagegoal().trim() + "%'"));
		}

		if (budget.getCounterpartaddress() != null && !"".equals(budget.getCounterpartaddress())) {
			sqlSb.append( " AND COUNTERPARTADDRESS LIKE '%" + (budget.getCounterpartaddress().trim() + "%'"));
		}

		if (budget.getFlowid() != null && !"".equals(budget.getFlowid())) {
			sqlSb.append( " and FLOWID=" + (budget.getFlowid()));
		}

		if (budget.getBlacktype() != null && (budget.getBlacktype() == 3)) {
			sqlSb.append( " AND BLACKTYPE IS NOT NULL");
		}

		sqlSb.append("  )ORDER BY BUDGETID DESC ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}


	public String findListByPageCount(String userid,BigDecimal orgid) throws Exception {
		TblCyhwProjectbudget budget = new TblCyhwProjectbudget();
		StringBuffer sqlSb = new StringBuffer("SELECT COUNT(*) from TBL_CYHW_PROJECTBUDGET where ORGID=" + orgid + "  and (BUDGETID in (select FROMID from TBL_MY_TASK where USRID=" + userid + ") or CREATEUSER=" + userid );

		if (budget.getBudgetname() != null && !"".equals(budget.getBudgetname())) {
			sqlSb.append(" AND budgetName LIKE '%" + (budget.getBudgetname() + "%'"));
		}

		if (budget.getCounterpartno() != null && !"".equals(budget.getCounterpartno())) {
			sqlSb.append( " AND counterpartNo LIKE '%" + (budget.getCounterpartno().trim() + "%'"));
		}

		if (budget.getProjectstagegoal() != null && !"".equals(budget.getProjectstagegoal())) {
			sqlSb.append( " AND PROJECTSTAGEGOAL LIKE '%" + (budget.getProjectstagegoal().trim() + "%'"));
		}

		if (budget.getCounterpartaddress() != null && !"".equals(budget.getCounterpartaddress())) {
			sqlSb.append( " AND COUNTERPARTADDRESS LIKE '%" + (budget.getCounterpartaddress().trim() + "%'"));
		}

		if (budget.getFlowid() != null && !"".equals(budget.getFlowid())) {
			sqlSb.append( " and FLOWID=" + (budget.getFlowid()));
		}

		if (budget.getBlacktype() != null && (budget.getBlacktype() == 3)) {
			sqlSb.append( " AND BLACKTYPE IS NOT NULL");
		}

		sqlSb.append("  )ORDER BY BUDGETID DESC");
		String sql = sqlSb.toString();
		return sql;
	}


	public String findListByPageInfoTcpb(PageInfo<TblCyhwProjectbudget> pageInfo, BigDecimal orgid, TblCyhwProjectbudget tcpb) throws Exception {

		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT * from TBL_CYHW_PROJECTBUDGET  where ORGID=" + orgid);

		if (tcpb.getBudgetname() != null && !"".equals(tcpb.getBudgetname())) {
			sqlSb.append( "  AND budgetName LIKE '%" + (tcpb.getBudgetname() + "%'"));
		}

		if (tcpb.getFlowid() != null && !"".equals(tcpb.getFlowid())) {
			sqlSb.append( " and FLOWID=" + (tcpb.getFlowid()));
		}

		if (tcpb.getRecordtype() != null && !"".equals(tcpb.getRecordtype())) {
			sqlSb.append( " AND RECORDTYPE = '" + (tcpb.getRecordtype() + "'"));
		}

		if (tcpb.getInspectionstatus() != null && !"".equals(tcpb.getInspectionstatus())) {
			sqlSb.append( " AND INSPECTIONSTATUS = '" + (tcpb.getInspectionstatus() + "'"));
		}

		if (tcpb.getCounterpartno() != null && !"".equals(tcpb.getCounterpartno())) {
			sqlSb.append( " AND counterpartNo LIKE '%" + (tcpb.getCounterpartno().trim() + "%'"));
		}

		if (tcpb.getProjectstagegoal() != null && !"".equals(tcpb.getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + (tcpb.getProjectstagegoal().trim() + "%'"));
		}

		if (tcpb.getCounterpartaddress() != null && !"".equals(tcpb.getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%" + (tcpb.getCounterpartaddress().trim() + "%'"));
		}

		if (tcpb.getBlacktype() != null && (tcpb.getBlacktype() == 3)) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");
		}

		if (tcpb.getIsblack() != null && (tcpb.getIsblack() == 2)) {
			sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
		}

		sqlSb.append(" ORDER BY BUDGETID DESC ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}

	public String findListByPageInfoTcpbCount(BigDecimal orgid, TblCyhwProjectbudget tcpb) throws Exception {

		StringBuffer sqlSb = new StringBuffer("SELECT * from TBL_CYHW_PROJECTBUDGET  where ORGID=" + orgid);

		if (tcpb.getBudgetname() != null && !"".equals(tcpb.getBudgetname())) {
			sqlSb.append( "  AND budgetName LIKE '%" + (tcpb.getBudgetname() + "%'"));
		}

		if (tcpb.getFlowid() != null && !"".equals(tcpb.getFlowid())) {
			sqlSb.append( " and FLOWID=" + (tcpb.getFlowid()));
		}

		if (tcpb.getRecordtype() != null && !"".equals(tcpb.getRecordtype())) {
			sqlSb.append( " AND RECORDTYPE = '" + (tcpb.getRecordtype() + "'"));
		}

		if (tcpb.getInspectionstatus() != null && !"".equals(tcpb.getInspectionstatus())) {
			sqlSb.append( " AND INSPECTIONSTATUS = '" + (tcpb.getInspectionstatus() + "'"));
		}

		if (tcpb.getCounterpartno() != null && !"".equals(tcpb.getCounterpartno())) {
			sqlSb.append( " AND counterpartNo LIKE '%" + (tcpb.getCounterpartno().trim() + "%'"));
		}

		if (tcpb.getProjectstagegoal() != null && !"".equals(tcpb.getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + (tcpb.getProjectstagegoal().trim() + "%'"));
		}

		if (tcpb.getCounterpartaddress() != null && !"".equals(tcpb.getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%" + (tcpb.getCounterpartaddress().trim() + "%'"));
		}

		if (tcpb.getBlacktype() != null && (tcpb.getBlacktype() == 3)) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");
		}

		if (tcpb.getIsblack() != null && (tcpb.getIsblack() == 2)) {
			sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
		}

		//sqlSb.append(" ORDER BY BUDGETID DESC ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}


	public String findListByPageTcpb(PageInfo<TblCyhwProjectbudget> pageInfo, String staffid, BigDecimal orgid, TblCyhwProjectbudget tcpb) throws Exception {

		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT * from TBL_CYHW_PROJECTBUDGET where ORGID=" + orgid + "  and (BUDGETID in (select FROMID from TBL_MY_TASK where USRID=" + staffid + ") or CREATEUSER=" + staffid );

		if (tcpb.getBudgetname() != null && !"".equals(tcpb.getBudgetname())) {
			sqlSb.append( " AND BUDGETNAME LIKE '%" + (tcpb.getBudgetname() + "%'"));
		}

		if (tcpb.getCounterpartno() != null && !"".equals(tcpb.getCounterpartno())) {
			sqlSb.append(" AND counterpartNo LIKE '%" + (tcpb.getCounterpartno().trim() + "%'"));
		}

		if (tcpb.getProjectstagegoal() != null && !"".equals(tcpb.getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + (tcpb.getProjectstagegoal().trim() + "%'"));
		}

		if (tcpb.getCounterpartaddress() != null && !"".equals(tcpb.getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%" + (tcpb.getCounterpartaddress().trim() + "%'"));
		}

		if (tcpb.getFlowid() != null && !"".equals(tcpb.getFlowid())) {
			sqlSb.append(" and FLOWID=" + (tcpb.getFlowid()));
		}

		if (tcpb.getBlacktype() != null && (tcpb.getBlacktype() == 3)) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");
		}

		sqlSb.append(" )ORDER BY BUDGETID DESC ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}


	public String findListByPageTcpbCount(String staffid, BigDecimal orgid, TblCyhwProjectbudget tcpb) throws Exception {

		StringBuffer sqlSb = new StringBuffer("SELECT * from TBL_CYHW_PROJECTBUDGET where ORGID=" + orgid + "  and (BUDGETID in (select FROMID from TBL_MY_TASK where USRID=" + staffid + ") or CREATEUSER=" + staffid );

		if (tcpb.getBudgetname() != null && !"".equals(tcpb.getBudgetname())) {
			sqlSb.append( " AND BUDGETNAME LIKE '%" + (tcpb.getBudgetname() + "%'"));
		}

		if (tcpb.getCounterpartno() != null && !"".equals(tcpb.getCounterpartno())) {
			sqlSb.append(" AND counterpartNo LIKE '%" + (tcpb.getCounterpartno().trim() + "%'"));
		}

		if (tcpb.getProjectstagegoal() != null && !"".equals(tcpb.getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + (tcpb.getProjectstagegoal().trim() + "%'"));
		}

		if (tcpb.getCounterpartaddress() != null && !"".equals(tcpb.getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%" + (tcpb.getCounterpartaddress().trim() + "%'"));
		}

		if (tcpb.getFlowid() != null && !"".equals(tcpb.getFlowid())) {
			sqlSb.append(" and FLOWID=" + (tcpb.getFlowid()));
		}

		if (tcpb.getBlacktype() != null && (tcpb.getBlacktype() == 3)) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");
		}

		sqlSb.append(" )ORDER BY BUDGETID DESC");
		String sql = sqlSb.toString();
		return sql;
	}


	public String selectListByPageInfoStaff(PageInfo<TblCyhwProjectbudget> pageInfo, TblStaffUtil staff) {
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT * from TBL_CYHW_PROJECTBUDGET TCP where ORGID = "+staff.getCurrentOrg().getOrgid());

//		if(taskCount > 0) {
//			sqlSb.append(" and (BUDGETID in (select FROMID from TBL_MY_TASK where USRID = "+staff.getStaffid()+" ) or CREATEUSER = "+staff.getStaffid()+" )");
//		}
		TblCyhwProjectbudget budget = pageInfo.getCondition();
		if(budget.getBudgetname() != null && !"".equals(budget.getBudgetname())) {
			sqlSb.append(" AND TCP.BUDGETNAME LIKE '%"+budget.getBudgetname()+"%'");
		}
		if(budget.getFlowid() != null && !"".equals(budget.getFlowid())) {
			sqlSb.append(" AND TCP.FLOWID = "+budget.getFlowid()+"");
		}
		if(budget.getRecordtype() != null && !"".equals(budget.getRecordtype())) {
			sqlSb.append(" AND TCP.RECORDTYPE = '"+pageInfo.getCondition().getRecordtype()+"'");
		}
		if(budget.getInspectionstatus() != null && !"".equals(budget.getInspectionstatus())) {
			sqlSb.append("AND TCP.INSPECTIONSTATUS = '"+budget.getInspectionstatus()+"'");
		}
		if(budget.getCounterpartno()!=null && !"".equals(budget.getCounterpartno())) {
			sqlSb.append(" AND TCP.COUNTERPARTNO LIKE '%"+budget.getCounterpartno().trim()+"%'");
		}
		if(budget.getProjectstagegoal() != null && !"".equals(budget.getProjectgoal())) {
			sqlSb.append(" AND TCP.PROJECTSTAGEGOAL LIKE '%"+budget.getProjectgoal().trim()+"%'");
		}
		if(budget.getCounterpartaddress() != null && !"".equals(budget.getCounterpartaddress())) {
			sqlSb.append(" AND TCP.COUNTERPARTADDRESS LIKE '%"+budget.getCounterpartaddress().trim()+"%'");
		}
		if(budget.getBlacktype() != null && budget.getBlacktype()==3) {

		}
		if(budget.getIsblack() != null) {
			if( budget.getBlacktype()==3) {
				sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
			}else if(budget.getIsblack() == 2) {
				sqlSb.append(" AND ISBLACK = 2");
			}else if(budget.getIsblack() == 1) {
				sqlSb.append(" AND (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE)");
			}
		}
		sqlSb.append(" ORDER BY BUDGETID DESC ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}


	public String selectCountByPageInfoStaff(PageInfo<TblCyhwProjectbudget> pageInfo, TblStaffUtil staff) {
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT * from TBL_CYHW_PROJECTBUDGET TCP where ORGID = "+staff.getCurrentOrg().getOrgid());

//		if(taskCount > 0) {
//			sqlSb.append(" and (BUDGETID in (select FROMID from TBL_MY_TASK where USRID = "+staff.getStaffid()+" ) or CREATEUSER = "+staff.getStaffid()+" )");
//		}
		TblCyhwProjectbudget budget = pageInfo.getCondition();
		if(budget.getBudgetname() != null && !"".equals(budget.getBudgetname())) {
			sqlSb.append(" AND TCP.BUDGETNAME LIKE '%"+budget.getBudgetname()+"%'");
		}
		if(budget.getFlowid() != null && !"".equals(budget.getFlowid())) {
			sqlSb.append(" AND TCP.FLOWID = "+budget.getFlowid()+"");
		}
		if(budget.getRecordtype() != null && !"".equals(budget.getRecordtype())) {
			sqlSb.append(" AND TCP.RECORDTYPE = '"+pageInfo.getCondition().getRecordtype()+"'");
		}
		if(budget.getInspectionstatus() != null && !"".equals(budget.getInspectionstatus())) {
			sqlSb.append("AND TCP.INSPECTIONSTATUS = '"+budget.getInspectionstatus()+"'");
		}
		if(budget.getCounterpartno()!=null && !"".equals(budget.getCounterpartno())) {
			sqlSb.append(" AND TCP.COUNTERPARTNO LIKE '%"+budget.getCounterpartno().trim()+"%'");
		}
		if(budget.getProjectstagegoal() != null && !"".equals(budget.getProjectgoal())) {
			sqlSb.append(" AND TCP.PROJECTSTAGEGOAL LIKE '%"+budget.getProjectgoal().trim()+"%'");
		}
		if(budget.getCounterpartaddress() != null && !"".equals(budget.getCounterpartaddress())) {
			sqlSb.append(" AND TCP.COUNTERPARTADDRESS LIKE '%"+budget.getCounterpartaddress().trim()+"%'");
		}
		if(budget.getBlacktype() != null && budget.getBlacktype()==3) {

		}
		if(budget.getIsblack() != null) {
			if( budget.getBlacktype()==3) {
				sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
			}else if(budget.getIsblack() == 2) {
				sqlSb.append(" AND ISBLACK = 2");
			}else if(budget.getIsblack() == 1) {
				sqlSb.append(" AND (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE)");
			}
		}
		sqlSb.append(" ORDER BY BUDGETID DESC ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}
	
	public String selectOppsiteBlackList(PageInfo<TblCyhwProjectbudget> pageInfo, TblStaffUtil staff,boolean taskCount) {
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT * from TBL_CYHW_PROJECTBUDGET   where ORGID = "+staff.getCurrentOrg().getOrgid()+" AND RECORDTYPE = 'HTGL001'");
		TblCyhwProjectbudget tcb = pageInfo.getCondition();
		
		if(!taskCount) {
			sqlSb.append(" AND  (BUDGETID in (select FROMID from TBL_MY_TASK where USRID="+staff.getStaffid()+") or CREATEUSER="+staff.getStaffid()+" ) ");
		}
		
		
		if (tcb.getBudgetname() != null && !"".equals(tcb.getBudgetname())) {
			sqlSb.append("  AND BUDGETNAME LIKE '%" + tcb.getBudgetname()+ "%'");
		}
	
		if (tcb.getRecordtype() != null && !"".equals(tcb.getRecordtype())) {
			sqlSb.append(" AND RECORDTYPE = '" + tcb.getRecordtype() + "'");
		}
	
		if (tcb.getInspectionstatus() != null && !"".equals(tcb.getInspectionstatus())) {
			sqlSb.append(" AND INSPECTIONSTATUS = '" + tcb.getInspectionstatus() + "'");
		}
	
		if (tcb.getCounterpartno() != null && !"".equals(tcb.getCounterpartno())) {
			sqlSb.append(" AND COUNTERPARTNO LIKE '%" + tcb.getCounterpartno().trim() + "%'");
		}
	
		if (tcb.getProjectstagegoal() != null && !"".equals(tcb.getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + tcb.getProjectstagegoal().trim() + "%'");
		}
	
		if (tcb.getCounterpartaddress() != null && !"".equals(tcb.getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%" + tcb.getCounterpartaddress().trim() + "%'");
		}
	
		if (tcb.getBlacktype() != null && tcb.getBlacktype() == 3) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");
		}
	
		if(tcb.getIsblack() != null) {
			if(tcb.getIsblack() == 2) {
				sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
			}
		}
		sqlSb.append(" ORDER BY BUDGETID DESC ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
		
	}

	public String selectOppsiteBlackListCount(PageInfo<TblCyhwProjectbudget> pageInfo,TblStaffUtil staff, boolean taskCount) {
		StringBuffer sqlSb = new StringBuffer("SELECT COUNT(*) from TBL_CYHW_PROJECTBUDGET   where ORGID = "+staff.getCurrentOrg().getOrgid()+" AND RECORDTYPE = 'HTGL001'");
		TblCyhwProjectbudget tcb = pageInfo.getCondition();
		
		if(!taskCount) {
			sqlSb.append(" AND  (BUDGETID in (select FROMID from TBL_MY_TASK where USRID="+staff.getStaffid()+") or CREATEUSER="+staff.getStaffid()+" ) ");
		}
		
		if (tcb.getBudgetname() != null && !"".equals(tcb.getBudgetname())) {
			sqlSb.append("  AND BUDGETNAME LIKE '%" + tcb.getBudgetname()+ "%'");
		}

		if (tcb.getRecordtype() != null && !"".equals(tcb.getRecordtype())) {
			sqlSb.append(" AND RECORDTYPE = '" + tcb.getRecordtype() + "'");
		}

		if (tcb.getInspectionstatus() != null && !"".equals(tcb.getInspectionstatus())) {
			sqlSb.append(" AND INSPECTIONSTATUS = '" + tcb.getInspectionstatus() + "'");
		}

		if (tcb.getCounterpartno() != null && !"".equals(tcb.getCounterpartno())) {
			sqlSb.append(" AND COUNTERPARTNO LIKE '%" + tcb.getCounterpartno().trim() + "%'");
		}

		if (tcb.getProjectstagegoal() != null && !"".equals(tcb.getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + tcb.getProjectstagegoal().trim() + "%'");
		}

		if (tcb.getCounterpartaddress() != null && !"".equals(tcb.getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%" + tcb.getCounterpartaddress().trim() + "%'");
		}

		if (tcb.getBlacktype() != null && tcb.getBlacktype() == 3) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");
		}

		if (tcb.getIsblack() != null && tcb.getIsblack() == 2) {
			sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
		}

		sqlSb.append(" ORDER BY BUDGETID DESC ");
		String sql = sqlSb.toString();
		return sql;
	}
	
	
	public String selectListByPageInfoFlowidTaskCount(PageInfo<TblCyhwProjectbudget> pageInfo, TblStaffUtil staff, Integer taskCount, String flowid) {
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT * from TBL_CYHW_PROJECTBUDGET   where ORGID = "+staff.getCurrentOrg().getOrgid()+" and FLOWID ="+622322);
			TblCyhwProjectbudget tcb = new TblCyhwProjectbudget();
		if (tcb.getBudgetname() != null && !"".equals(tcb.getBudgetname())) {
			sqlSb.append("  AND BUDGETNAME LIKE '%" + tcb.getBudgetname()+ "%'");
		}

		if (tcb.getRecordtype() != null && !"".equals(tcb.getRecordtype())) {
			sqlSb.append(" AND RECORDTYPE = '" + tcb.getRecordtype() + "'");
		}

		if (tcb.getInspectionstatus() != null && !"".equals(tcb.getInspectionstatus())) {
			sqlSb.append(" AND INSPECTIONSTATUS = '" + tcb.getInspectionstatus() + "'");
		}

		if (tcb.getCounterpartno() != null && !"".equals(tcb.getCounterpartno())) {
			sqlSb.append(" AND COUNTERPARTNO LIKE '%" + tcb.getCounterpartno().trim() + "%'");
		}

		if (tcb.getProjectstagegoal() != null && !"".equals(tcb.getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + tcb.getProjectstagegoal().trim() + "%'");
		}

		if (tcb.getCounterpartaddress() != null && !"".equals(tcb.getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%" + tcb.getCounterpartaddress().trim() + "%'");
		}

		if (tcb.getBlacktype() != null && tcb.getBlacktype() == 3) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");
		}


		if(tcb.getIsblack() != null) {
			if(tcb.getIsblack() == 2) {
				sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
			}
		}


		sqlSb.append(" ORDER BY BUDGETID DESC ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}

	public String selectListByPageInfoFlowidTaskCountCount(TblStaffUtil staff, Integer taskCount, String flowid) {
		StringBuffer sqlSb = new StringBuffer("SELECT COUNT(*) from TBL_CYHW_PROJECTBUDGET   where ORGID = "+staff.getCurrentOrg().getOrgid()+" and FLOWID ="+622322);
		TblCyhwProjectbudget tcb = new TblCyhwProjectbudget();
		if (tcb.getBudgetname() != null && !"".equals(tcb.getBudgetname())) {
			sqlSb.append("  AND BUDGETNAME LIKE '%" + tcb.getBudgetname()+ "%'");
		}

		if (tcb.getRecordtype() != null && !"".equals(tcb.getRecordtype())) {
			sqlSb.append(" AND RECORDTYPE = '" + tcb.getRecordtype() + "'");
		}

		if (tcb.getInspectionstatus() != null && !"".equals(tcb.getInspectionstatus())) {
			sqlSb.append(" AND INSPECTIONSTATUS = '" + tcb.getInspectionstatus() + "'");
		}

		if (tcb.getCounterpartno() != null && !"".equals(tcb.getCounterpartno())) {
			sqlSb.append(" AND COUNTERPARTNO LIKE '%" + tcb.getCounterpartno().trim() + "%'");
		}

		if (tcb.getProjectstagegoal() != null && !"".equals(tcb.getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + tcb.getProjectstagegoal().trim() + "%'");
		}

		if (tcb.getCounterpartaddress() != null && !"".equals(tcb.getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%" + tcb.getCounterpartaddress().trim() + "%'");
		}

		if (tcb.getBlacktype() != null && tcb.getBlacktype() == 3) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");
		}

		if (tcb.getIsblack() != null && tcb.getIsblack() == 2) {
			sqlSb.append(" AND ((ISBLACK = 2 OR ISBLACK IS NULL) OR (ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE))");
		}

		sqlSb.append(" ORDER BY BUDGETID DESC ");
		String sql = sqlSb.toString();
		return sql;
	}


	public String selectCountByPageInfoStaffTaskCount(PageInfo<TblCyhwProjectbudget> pageInfo, TblStaffUtil staff, String flowid) {

		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT * from TBL_CYHW_PROJECTBUDGET where ORGID=" + staff.getCurrentOrg().getOrderid() + "  and (BUDGETID in (select FROMID from TBL_MY_TASK where USRID=" + staff.getStaffid() + ") or CREATEUSER=" + staff.getStaffid() + " AND ISBLACK != 2 and FLOWID = "+622322+")");
		TblCyhwProjectbudget tcb = new TblCyhwProjectbudget();

		if (tcb.getBudgetname() != null && !"".equals(tcb.getBudgetname())) {
			sqlSb.append(" AND BUDGETNAME LIKE '%" + tcb.getBudgetname() + "%'");
		}

		if (tcb.getCounterpartno() != null && !"".equals(tcb.getCounterpartno())) {
			sqlSb.append(" AND COUNTERPARTNO LIKE '%" + tcb.getCounterpartno().trim() + "%'");
		}

		if (tcb.getProjectstagegoal() != null && !"".equals(tcb.getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + tcb.getProjectstagegoal().trim() + "%'");
		}

		if (tcb.getCounterpartaddress() != null && !"".equals(tcb.getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%" + tcb.getCounterpartaddress().trim() + "%'");
		}


		if (tcb.getBlacktype() != null && tcb.getBlacktype() == 3) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");
		}

		sqlSb.append(" ORDER BY BUDGETID DESC ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}

	public String selectCountByPageInfoStaffTaskCo(TblStaffUtil staff, String flowid) {

		StringBuffer sqlSb = new StringBuffer("SELECT COUNT(*) from TBL_CYHW_PROJECTBUDGET where ORGID=" + staff.getCurrentOrg().getOrderid() + "  and (BUDGETID in (select FROMID from TBL_MY_TASK where USRID=" + staff.getStaffid() + ") or CREATEUSER=" + staff.getStaffid() + " AND ISBLACK != 2 and FLOWID = "+622322+")");
		TblCyhwProjectbudget tcb = new TblCyhwProjectbudget();

		if (tcb.getBudgetname() != null && !"".equals(tcb.getBudgetname())) {
			sqlSb.append(" AND BUDGETNAME LIKE '%" + tcb.getBudgetname() + "%'");
		}

		if (tcb.getCounterpartno() != null && !"".equals(tcb.getCounterpartno())) {
			sqlSb.append(" AND COUNTERPARTNO LIKE '%" + tcb.getCounterpartno().trim() + "%'");
		}

		if (tcb.getProjectstagegoal() != null && !"".equals(tcb.getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + tcb.getProjectstagegoal().trim() + "%'");
		}

		if (tcb.getCounterpartaddress() != null && !"".equals(tcb.getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%" + tcb.getCounterpartaddress().trim() + "%'");
		}


		if (tcb.getBlacktype() != null && tcb.getBlacktype() == 3) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");
		}

		sqlSb.append(" ORDER BY BUDGETID DESC ");
		String sql = sqlSb.toString();
		return sql;
	}


	public String selectListByPageInfoFlowidTask(PageInfo<TblCyhwProjectbudget> pageInfo, TblStaffUtil staff, boolean taskCount, String flowid) {
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT * from TBL_CYHW_PROJECTBUDGET   where ORGID = "+staff.getCurrentOrg().getOrgid()+" AND ISBLACK != 2 and FLOWID ="+622322);
		TblCyhwProjectbudget tcb = new TblCyhwProjectbudget();
		if (tcb.getBudgetname() != null && !"".equals(tcb.getBudgetname())) {
			sqlSb.append("  AND BUDGETNAME LIKE '%" + tcb.getBudgetname()+ "%'");
		}

		if (tcb.getRecordtype() != null && !"".equals(tcb.getRecordtype())) {
			sqlSb.append(" AND RECORDTYPE = '" + tcb.getRecordtype() + "'");
		}

		if (tcb.getInspectionstatus() != null && !"".equals(tcb.getInspectionstatus())) {
			sqlSb.append(" AND INSPECTIONSTATUS = '" + tcb.getInspectionstatus() + "'");
		}

		if (tcb.getCounterpartno() != null && !"".equals(tcb.getCounterpartno())) {
			sqlSb.append(" AND COUNTERPARTNO LIKE '%" + tcb.getCounterpartno().trim() + "%'");
		}

		if (tcb.getProjectstagegoal() != null && !"".equals(tcb.getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + tcb.getProjectstagegoal().trim() + "%'");
		}

		if (tcb.getCounterpartaddress() != null && !"".equals(tcb.getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%" + tcb.getCounterpartaddress().trim() + "%'");
		}

		if (tcb.getBlacktype() != null && tcb.getBlacktype() == 3) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");
		}


		if(tcb.getIsblack() != null) {
			if(tcb.getIsblack() == 2) {
				sqlSb.append(" AND ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE");
			}
		}


		sqlSb.append(" ORDER BY BUDGETID DESC ) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}


	public String selectListByPageInfoFlowidTaskCo(TblStaffUtil staff, boolean taskCount, String flowid) {
		StringBuffer sqlSb = new StringBuffer("SELECT COUNT(*) from TBL_CYHW_PROJECTBUDGET   where ORGID = "+staff.getCurrentOrg().getOrgid()+" AND ISBLACK != 2 and FLOWID ="+622322);
		TblCyhwProjectbudget tcb = new TblCyhwProjectbudget();
		if (tcb.getBudgetname() != null && !"".equals(tcb.getBudgetname())) {
			sqlSb.append("  AND BUDGETNAME LIKE '%" + tcb.getBudgetname()+ "%'");
		}

		if (tcb.getRecordtype() != null && !"".equals(tcb.getRecordtype())) {
			sqlSb.append(" AND RECORDTYPE = '" + tcb.getRecordtype() + "'");
		}

		if (tcb.getInspectionstatus() != null && !"".equals(tcb.getInspectionstatus())) {
			sqlSb.append(" AND INSPECTIONSTATUS = '" + tcb.getInspectionstatus() + "'");
		}

		if (tcb.getCounterpartno() != null && !"".equals(tcb.getCounterpartno())) {
			sqlSb.append(" AND COUNTERPARTNO LIKE '%" + tcb.getCounterpartno().trim() + "%'");
		}

		if (tcb.getProjectstagegoal() != null && !"".equals(tcb.getProjectstagegoal())) {
			sqlSb.append(" AND PROJECTSTAGEGOAL LIKE '%" + tcb.getProjectstagegoal().trim() + "%'");
		}

		if (tcb.getCounterpartaddress() != null && !"".equals(tcb.getCounterpartaddress())) {
			sqlSb.append(" AND COUNTERPARTADDRESS LIKE '%" + tcb.getCounterpartaddress().trim() + "%'");
		}

		if (tcb.getBlacktype() != null && tcb.getBlacktype() == 3) {
			sqlSb.append(" AND BLACKTYPE IS NOT NULL");
		}

		if(tcb.getIsblack() != null) {
			if(tcb.getIsblack() == 2) {
				sqlSb.append(" AND ISBLACK = 1 AND BLACKTYPE = 1 AND EFFECTDATE <= SYSDATE");
			}
		}

		sqlSb.append(" ORDER BY BUDGETID DESC ");
		String sql = sqlSb.toString();
		return sql;
	}
	
	

	public String getList(String orgid,String startDate) throws Exception {

		StringBuffer sqlSb = new StringBuffer("SELECT budgetid,budgetname,counterpartno from TBL_CYHW_PROJECTBUDGET where 1=1");

		if (!"".equals(orgid)&&!StringUtils.isEmpty(orgid)) {
			sqlSb.append( "  AND orgid ='"+orgid+"'");
		}

		if (!StringUtils.isEmpty(startDate)) {
			sqlSb.append( " and createtime >= to_date('"+startDate+"','yyyy-mm-dd') ");
		}
		String sql = sqlSb.toString();
		return sql;
	}
	
	
	public String insertOppositePartyOld(TblCyhwProjectbudget tcpb) {
		StringBuffer column = new StringBuffer("INSERT INTO TBL_CYHW_PROJECTBUDGET (BUDGETID");
		StringBuffer value = new StringBuffer(" VALUES (CYHWBUDGET_SEQUENCE.nextval");
		
		if(tcpb.getBudgetname() != null) {
			column.append(",BUDGETNAME");
			value.append(",'"+tcpb.getBudgetname()+"'");
		}
		if(tcpb.getTotaltmoney() != null) {
			column.append(",TOTALTMONEY");
			value.append(",'"+tcpb.getTotaltmoney()+"'");
		}
		if(tcpb.getFinancemoney() != null) {
			column.append(",FINANCEMONEY");
			value.append(",'"+tcpb.getFinancemoney()+"'");
		}
		if(tcpb.getOthermoney() != null) {
			column.append(",OTHERMONEY");
			value.append(",'"+tcpb.getOthermoney()+"'");
		}
		if(tcpb.getGoodstype() != null) {
			column.append(",GOODSTYPE");
			value.append(",'"+tcpb.getGoodstype()+"'");
		}
		if(tcpb.getServicetype() != null) {
			column.append(",SERVICETYPE");
			value.append(",'"+tcpb.getServicetype()+"'");
		}
		if(tcpb.getProjecttype() != null) {
			column.append(",PROJECTTYPE");
			value.append(",'"+tcpb.getProjecttype()+"'");
		}
		if(tcpb.getOrthertype() != null) {
			column.append(",ORTHERTYPE");
			value.append(",'"+tcpb.getOrthertype()+"'");
		}
		if(tcpb.getIsgovernment() != null) {
			column.append(",ISGOVERNMENT");
			value.append(",'"+tcpb.getIsgovernment()+"'");
		}
		if(tcpb.getIsdirect() != null) {
			column.append(",ISDIRECT");
			value.append(",'"+tcpb.getIsdirect()+"'");
		}
		if(tcpb.getItembudgettype() != null) {
			column.append(",ITEMBUDGETTYPE");
			value.append(",'"+tcpb.getItembudgettype()+"'");
		}
		if(tcpb.getProjecteason() != null) {
			column.append(",PROJECTEASON");
			value.append(",'"+tcpb.getProjecteason()+"'");
		}
		if(tcpb.getProjectgoal() != null) {
			column.append(",PROJECTGOAL");
			value.append(",'"+tcpb.getProjectgoal()+"'");
		}
		if(tcpb.getProjectstagegoal() != null) {
			column.append(",PROJECTSTAGEGOAL");
			value.append(",'"+tcpb.getProjectstagegoal()+"'");
		}
		if(tcpb.getProjectcondition() != null) {
			column.append(",PROJECTCONDITION");
			value.append(",'"+tcpb.getProjectcondition()+"'");
		}
		if(tcpb.getProjectrisk() != null) {
			column.append(",PROJECTRISK");
			value.append(",'"+tcpb.getProjectrisk()+"'");
		}
		if(tcpb.getOrgid() != null) {
			column.append(",ORGID");
			value.append(",'"+tcpb.getOrgid()+"'");
		}
		if(tcpb.getCreateuser() != null) {
			column.append(",CREATEUSER");
			value.append(",'"+tcpb.getCreateuser()+"'");
		}
		if(tcpb.getCreatetime() != null) {
			column.append(",CREATETIME");
			value.append(",TO_DATE('"+DateUtil.parseDate(tcpb.getCreatetime(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getFlowid() != null) {
			column.append(",FLOWID");
			value.append(",'"+tcpb.getFlowid()+"'");
		}
		if(tcpb.getLinkdepr() != null) {
			column.append(",LINKDEPR");
			value.append(",'"+tcpb.getLinkdepr()+"'");
		}
		if(tcpb.getReporttodept() != null) {
			column.append(",REPORTTODEPT");
			value.append(",'"+tcpb.getReporttodept()+"'");
		}
		if(tcpb.getInspectionstatus() != null) {
			column.append(",INSPECTIONSTATUS");
			value.append(",'"+tcpb.getInspectionstatus()+"'");
		}
		if(tcpb.getGoodsprice() != null) {
			column.append(",GOODSPRICE");
			value.append(",'"+tcpb.getGoodsprice()+"'");
		}
		if(tcpb.getGoodsamount() != null) {
			column.append(",GOODSAMOUNT");
			value.append(",'"+tcpb.getGoodsamount()+"'");
		}
		if(tcpb.getGoodsmodel() != null) {
			column.append(",GOODSMODEL");
			value.append(",'"+tcpb.getGoodsmodel()+"'");
		}
		if(tcpb.getCounterpartno() != null) {
			column.append(",COUNTERPARTNO");
			value.append(",'"+tcpb.getCounterpartno()+"'");
		}
		if(tcpb.getCounterpartaddress() != null) {
			column.append(",COUNTERPARTADDRESS");
			value.append(",'"+tcpb.getCounterpartaddress()+"'");
		}
		if(tcpb.getCounterpartcode() != null) {
			column.append(",COUNTERPARTCODE");
			value.append(",'"+tcpb.getCounterpartcode()+"'");
		}
		if(tcpb.getCounterparthank() != null) {
			column.append(",COUNTERPARTHANK");
			value.append(",'"+tcpb.getCounterparthank()+"'");
		}
		if(tcpb.getCounterparthankaccount() != null) {
			column.append(",COUNTERPARTHANKACCOUNT");
			value.append(",'"+tcpb.getCounterparthankaccount()+"'");
		}
		if(tcpb.getCounterpartnetaddress() != null) {
			column.append(",COUNTERPARTNETADDRESS");
			value.append(",'"+tcpb.getCounterpartnetaddress()+"'");
		}
		if(tcpb.getCounterpartphone() != null) {
			column.append(",COUNTERPARTPHONE");
			value.append(",'"+tcpb.getCounterpartphone()+"'");
		}
		if(tcpb.getRecordtype() != null) {
			column.append(",RECORDTYPE");
			value.append(",'"+tcpb.getRecordtype()+"'");
		}
		if(tcpb.getRecordparent() != null) {
			column.append(",RECORDPARENT");
			value.append(",'"+tcpb.getRecordparent()+"'");
		}
		if(tcpb.getRecordconcat() != null) {
			column.append(",RECORDCONCAT");
			value.append(",'"+tcpb.getRecordconcat()+"'");
		}
		if(tcpb.getAction() != null) {
			column.append(",ACTION");
			value.append(",'"+tcpb.getAction()+"'");
		}
		if(tcpb.getEqbflowid() != null) {
			column.append(",EQBFLOWID");
			value.append(",'"+tcpb.getEqbflowid()+"'");
		}
		if(tcpb.getBizno() != null) {
			column.append(",BIZNO");
			value.append(",'"+tcpb.getBizno()+"'");
		}
		if(tcpb.getResultdescription() != null) {
			column.append(",RESULTDESCRIPTION");
			value.append(",'"+tcpb.getResultdescription()+"'");
		}
		if(tcpb.getEqbstatus() != null) {
			column.append(",EQBSTATUS");
			value.append(",'"+tcpb.getEqbstatus()+"'");
		}
		if(tcpb.getFlowtype() != null) {
			column.append(",FLOWTYPE");
			value.append(",'"+tcpb.getFlowtype()+"'");
		}
		if(tcpb.getEabfileck() != null) {
			column.append(",EABFILECK");
			value.append(",'"+tcpb.getEabfileck()+"'");
		}
		if(tcpb.getFileurl() != null) {
			column.append(",FILEURL");
			value.append(",'"+tcpb.getFileurl()+"'");
		}
		if(tcpb.getOppositenature() != null) {
			column.append(",OPPOSITENATURE");
			value.append(",'"+tcpb.getOppositenature()+"'");
		}
		if(tcpb.getCounterparttype() != null) {
			column.append(",COUNTERPARTTYPE");
			value.append(",'"+tcpb.getCounterparttype()+"'");
		}
		if(tcpb.getIseffect() != null) {
			column.append(",ISEFFECT");
			value.append(",'"+tcpb.getIseffect()+"'");
		}
		if(tcpb.getCounterpartdesc() != null) {
			column.append(",COUNTERPARTDESC");
			value.append(",'"+tcpb.getCounterpartdesc()+"'");
		}
		if(tcpb.getSafeorg() != null) {
			column.append(",SAFEORG");
			value.append(",'"+tcpb.getSafeorg()+"'");
		}
		if(tcpb.getSafestaff() != null) {
			column.append(",SAFESTAFF");
			value.append(",'"+tcpb.getSafestaff()+"'");
		}
		if(tcpb.getEffectdate() != null) {
			column.append(",EFFECTDATE");
			value.append(",TO_DATE('"+DateUtil.parseDate(tcpb.getEffectdate(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getSafedate() != null) {
			column.append(",SAFEDATE");
			value.append(",TO_DATE('"+DateUtil.parseDate(tcpb.getSafedate(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getDirector() != null) {
			column.append(",DIRECTOR");
			value.append(",'"+tcpb.getDirector()+"'");
		}
		if(tcpb.getContacts() != null) {
			column.append(",CONTACTS");
			value.append(",'"+tcpb.getContacts()+"'");
		}
		if(tcpb.getContactsphone() != null) {
			column.append(",CONTACTSPHONE");
			value.append(",'"+tcpb.getContactsphone()+"'");
		}
		if(tcpb.getContactsadress() != null) {
			column.append(",CONTACTSADRESS");
			value.append(",'"+tcpb.getContactsadress()+"'");
		}
		if(tcpb.getContactsemail() != null) {
			column.append(",CONTACTSEMAIL");
			value.append(",'"+tcpb.getContactsemail()+"'");
		}
		if(tcpb.getStation() != null) {
			column.append(",STATION");
			value.append(",'"+tcpb.getStation()+"'");
		}
		if(tcpb.getCallname() != null) {
			column.append(",CALLNAME");
			value.append(",'"+tcpb.getCallname()+"'");
		}
		if(tcpb.getRemarks() != null) {
			column.append(",REMARKS");
			value.append(",'"+tcpb.getRemarks()+"'");
		}
		if(tcpb.getIsblack() != null) {
			column.append(",ISBLACK");
			value.append(",'"+tcpb.getIsblack()+"'");
		}
		if(tcpb.getBlacktype() != null) {
			column.append(",BLACKTYPE");
			value.append(",'"+tcpb.getBlacktype()+"'");
		}
		if(tcpb.getPstartdate() != null) {
			column.append(",PSTARTDATE");
			value.append(",TO_DATE('"+DateUtil.parseDate(tcpb.getPstartdate(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getPenddate() != null) {
			column.append(",PENDDATE");
			value.append(",TO_DATE('"+DateUtil.parseDate(tcpb.getPenddate(),"yyyy-MM-dd HH:mm:ss") +"', 'YYYY-MM-DD HH24:MI:SS')");
		}
		if(tcpb.getCretificateno() != null) {
			column.append(",CRETIFICATENO");
			value.append(",'"+tcpb.getCretificateno()+"'");
		}
		column.append(")");
		value.append(")");
		String sql = column.toString()+value.toString();
		return sql;
	}
}
